From 39200e75b6364f50acebf032d4aa1455a2bf0628 Mon Sep 17 00:00:00 2001 From: Olivier Fourdan Date: Wed, 23 Nov 2016 14:55:40 +0100 Subject: [PATCH] wayland: Place subsurfaces relative to their parent Now that subsurfaces can be created as child of another GdkWindow (and not just the root window), they must be placed according to the location of their parent, i.e. the abs_x/abs_y must be updated and taken int account when placing and moving subsurfaces under Wayland. https://bugzilla.gnome.org/show_bug.cgi?id=774917 --- gdk/gdkwindow.c | 7 +++++-- gdk/wayland/gdkwindow-wayland.c | 8 ++++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/gdk/gdkwindow.c b/gdk/gdkwindow.c index 3f2d526b23..83002b7243 100644 --- a/gdk/gdkwindow.c +++ b/gdk/gdkwindow.c @@ -796,9 +796,12 @@ recompute_visible_regions_internal (GdkWindow *private, old_abs_y = private->abs_y; /* Update absolute position */ - if (gdk_window_has_impl (private)) + if ((gdk_window_has_impl (private) && + private->window_type != GDK_WINDOW_SUBSURFACE) || + (gdk_window_is_toplevel (private) && + private->window_type == GDK_WINDOW_SUBSURFACE)) { - /* Native window starts here */ + /* Native windows and toplevel subsurfaces start here */ private->abs_x = 0; private->abs_y = 0; } diff --git a/gdk/wayland/gdkwindow-wayland.c b/gdk/wayland/gdkwindow-wayland.c index 12ce613222..5360c4b827 100644 --- a/gdk/wayland/gdkwindow-wayland.c +++ b/gdk/wayland/gdkwindow-wayland.c @@ -1263,7 +1263,9 @@ gdk_wayland_window_create_subsurface (GdkWindow *window) impl->display_server.wl_subsurface = wl_subcompositor_get_subsurface (display_wayland->subcompositor, impl->display_server.wl_surface, parent_impl->display_server.wl_surface); - wl_subsurface_set_position (impl->display_server.wl_subsurface, window->x, window->y); + wl_subsurface_set_position (impl->display_server.wl_subsurface, + window->x + window->abs_x, + window->y + window->abs_y); /* In order to synchronize the initial position with the initial frame * content, wait with making the subsurface desynchronized until after @@ -2592,7 +2594,9 @@ gdk_window_wayland_move_resize (GdkWindow *window, if (impl->display_server.wl_subsurface) { - wl_subsurface_set_position (impl->display_server.wl_subsurface, x, y); + wl_subsurface_set_position (impl->display_server.wl_subsurface, + window->x + window->abs_x, + window->y + window->abs_y); gdk_window_request_transient_parent_commit (window); } } -- 2.30.2